<template>
	<view class="order">
		<view class="list">
			<view class="item">
				<view class="item-inner">
					<view class="name">
						<view class="logo" >
							<view class="inner-img">
								<image src="https://qiniu-cdn.maeiyun.com/imgs/shangjia/anmo.png"></image>
							</view>
							<text>{{orderData.service&&orderData.service.title}}</text>
						</view>
						<view style="background-color: #FFE087;color: #DC7500;" class="status">
							投诉
						</view>
					</view>
					<view class="product">
						<image :src="orderData.service&&orderData.service.images[0]" @error="imageError($event,orderData)" mode="aspectFill"></image>
						<view class="detail">
							<view class="title">{{orderData.service&&orderData.service.title}}</view>
							<view class="text">{{orderData.subscribe_time}}</view>
							<view class="text">总价: <text style="color:#FF0000;">￥{{orderData.price}}</text></view>
							<view class="text">技师: <text style="color:#333333;">{{orderData.technician&&orderData.technician.real_name}}</text> </view>
						</view>
					</view>
					<view class="bottom-info">
						<view class="user-name">
							<view class="info-lines">
								<text class="title">用户姓名:</text>
								{{orderData.address&&orderData.address.real_name}}
							</view>
							<view class="info-lines" @click="callphone(orderData.address.mobile)">
								<text class="title">联系方式:</text>
								{{orderData.address&&orderData.address.mobile}}
								<image src="https://qiniu-cdn.maeiyun.com/imgs/shangjia/phone.png" mode=""></image>
							</view>
						</view>
						<view>
							<text class="title">用户地址:</text>	{{orderData.address&&orderData.address.address}}
						</view>
						<view style="margin-top: 10rpx;">
							<text class="title">用户申请时间:</text>	{{orderData.apply_time}}
						</view>
					</view>
				</view>

			</view>
			<view class="order-infos">
				<view class="title-order">
					<view class="lines"></view>
					<view class="">
						投诉原因
					</view>
				</view>
				<view class="return-text">
					<view>
						{{orderData.content}}
					</view>
				</view>
			</view>
			<view class="order-infos">
				<view class="title-order">
					<view class="lines" style="background-color: #3393FF;"></view>
					<view class="">
						处理结果
					</view>
				</view>
				<view class="return-text">
					<view v-if="orderData.status != 1">
						{{orderData.return_content}}
					</view>
					<textarea v-else name="" id="" cols="30" v-model="tuikuantext" rows="10" placeholder="请输入处理结果"></textarea>
				</view>
				<view class="withhold">
					扣除技师
					<input type="number" :disabled="orderData.status!=1" v-model="kouchumoney" placeholder="金额"/>
					元
				</view>
			</view>
			<view class="bottom-btns" v-if="orderData.status == 1">
				<view class="jie-btn btn" @click="back">返回列表</view>
				<view class="lines"></view>
				<view class="set-btn btn" @click="show1 = true">通过</view>
			</view>
		</view>
		<u-modal v-model="show1" show-cancel-button @confirm="dialogConfirm" :content="content"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				search: '',
				tab: 0,
				list: [],
				isShowBack: false,
				down: {
					auto: false
				},
				page: 1,
				show: false,
				orderData: {},
				kouchumoney:0,//扣除金额
				content:"确定通过该投诉？",
				show1:false,
				tuikuanprice:"",
				tuikuantext:"",
				id:""
			}
		},
		onLoad(option) {
			this.id = option.id
			this.orderDetail()
		},
		methods: {
			back(){
				uni.navigateBack()
			},
			callphone(mobile) {
				this.$util.makeCall(mobile)
			},
			showPopup(type){
				if(type == 1){ // 
					this.show2 = true
				}else{
					this.show1 = true
				}
			},
			orderDetail() {
				var that = this
				this.request.httpTokenRequest({
					url: "store.order/getOrderSfterSales",
					method: "get"
				}, {
					order_id:this.id
				}).then(function(res) {
					if (res.code == 0) {
						that.orderData = res.data
						if(res.data.status ==2){
							that.kouchumoney = res.data.deduction_price
						}
					} else {
						that.$util.msg(res.msg)
					}
				})
			},
			dialogConfirm(){ // 同意
				this.audit(2)
			},
			dialogInputConfirm(){ //驳回
				this.audit(1)
			},
			audit(type){
				var that = this
				this.request.httpTokenRequest({
					url: "store.order/checkOrderSfterSales",
					method: "POST"
				}, {
					order_id:this.id,
					deduction_price:this.kouchumoney,
					return_content:this.tuikuantext,
					status: type
				}).then(function(res) {
					console.log(res)
					if (res.code == 0) {
						that.$util.msg(res.msg)
						that.orderDetail()
					} else {
						that.$util.msg(res.msg)
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.list {
		padding: 30rpx 30rpx 0 30rpx;

		.item {
			background: #FFFFFF;
			border-radius: 10rpx;
			margin-bottom: 30rpx;

			.item-inner {
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 4rpx 4rpx rgba(232, 232, 232, 0.5);
				border-radius: 10rpx;
				padding: 30rpx;
			}

			.name {
				display: flex;
				align-items: flex-start;
				justify-content: space-between;

				.logo {
					display: flex;
					align-items: center;

					.inner-img {
						width: 40rpx;
						height: 40rpx;
						margin-right: 10rpx;
					}

					image {
						width: 40rpx;
						height: 40rpx;
					}

					text {
						font-size: 30rpx;
						font-weight: 400;
						color: #08090A;
						line-height: 42rpx;
						flex-grow: 1;
						width: 80%;
					}
				}

				.status {
					width: 124rpx;
					height: 41rpx;
					background: #FFE7E7;
					border-radius: 4rpx;
					font-size: 26rpx;
					font-weight: 400;
					color: #FF0000;
					line-height: 41rpx;
					text-align: center;
				}
			}

			.product {
				display: flex;
				margin: 30rpx 0 30rpx;

				image {
					width: 142rpx;
					height: 190rpx;
					margin-right: 23rpx;
				}

				.detail {
					flex: 1;

					.title {
						font-size: 28rpx;
						font-weight: 600;
						color: #333333;
						line-height: 40rpx;
					}

					.text {
						font-size: 24rpx;
						color: #656667;
						line-height: 33rpx;
						margin-top: 10rpx;
					}
				}
			}

			.bottom-info {
				background: #F5F7F8;
				border-radius: 10rpx;
				opacity: 0.8;
				padding: 20rpx;
				font-size: 24rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				line-height: 33rpx;
				color: #333333;

				.user-name {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-bottom: 10rpx;

					.info-lines {
						image {
							width: 22rpx;
							height: 22rpx;
							margin-left: 36rpx;
						}
					}
				}

				text {
					color: #656667 !important;
				}
			}

		}

		.order-infos {
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 4rpx 4rpx rgba(232, 232, 232, 0.5);
			border-radius: 10rpx;
			padding: 26rpx 30rpx;
			margin-bottom: 20rpx;
			.title-order {
				display: flex;
				align-items: center;
				font-size: 30rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 42rpx;
				margin-bottom: 10rpx;

				.lines {
					width: 6rpx;
					height: 30rpx;
					background: #FF2B2B;
					border-radius: 5rpx;
					margin-right: 10rpx;
				}
			}
			.return-text {
				height: 171rpx;
				background: #F7F9F9;
				border-radius: 10rpx;
				padding: 20rpx;
				font-size: 26rpx;
				font-weight: 400;
				color: #656667;
				line-height: 37rpx;
				textarea{
					font-size: 26rpx;
				}
			}
			.withhold{
				display: flex;
				align-items: center;
				font-size: 30rpx;
				font-weight: 400;
				color: #333333;
				line-height: 42rpx;
				margin-top: 30rpx;
				input{
					width: 435rpx;
					height: 68rpx;
					border-radius: 10rpx;
					border: 1rpx solid #979797;
					margin: 0 20rpx;
					text-indent: 1em;
				}
			}
		}
	}

	//
	.bottom-btns {
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin-top: 40rpx;

		.btn {
			width: 300rpx;
			height: 68rpx;
			background: #3393FF;
			border-radius: 34rpx;
			line-height: 68rpx;
			text-align: center;
		}

		.jie-btn {
			border: 1rpx solid #949494;
			background: #F5F7F8;
			color: #949494;
		}

		.set-btn {
			font-size: 34rpx;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>